<template>
	<view class="container">
		<view class="item2">
			<view class="item2_content" v-for="(item, index) in dataList" :key='index'>
				<view class="item" v-for="(item2, index) in item.contentList" :key='index2'>
					{{ item2.label }}：{{ item2.value }}
				</view>
			</view>
		</view>
		<view style="padding-top: 300rpx;" v-if='showEmpty'>
			<u-empty text="暂无数据" mode="list"></u-empty>
		</view>
	</view>
</template>

<script>
	import { formRecord } from '@/api/formRecord.js'
	export default{
		components: {},
		data() {
			return {
				page: 1,
				size: 20,
				dataList: [],
				showEmpty: false,
				isLastPage: false
			}
		},
		onLoad() {
			this.getDataList()
		},
		onPullDownRefresh() {
			this.page = 1
			this.getDataList()
		},
		onReachBottom() {
			if(this.isLastPage) {
				return
			}
			this.getDataList()
		},
		methods:{
			getDataList() {
				var params = {
					page: this.page,
					size: this.size,
				}
				params.formKey='house'
				if(!this.$storage.getStorageDataSync(this.$store.state.userInfo)){
					return
				}
				params.createUser=this.$storage.getStorageDataSync(this.$store.state.userInfo).id,
				formRecord.getFormRecordList(params).then(res => {
					uni.stopPullDownRefresh();
					if (res.data.code == 10000) {
						if(this.page == 1){
							this.dataList = []
						}
						var list = res.data.data.list
						this.dataList = [...this.dataList, ...list]
						this.showEmpty = this.dataList.length<1
						if (res.data.data.next) {
							this.page += 1
							this.isLastPage = false
						} else {
							this.isLastPage = true
						}
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.item2{
		display: flex;
		flex-direction: column;
		padding: 0 20rpx;
		background-color: #FFFFFF;
		.item2_content{
			display: flex;
			flex-direction: column;
			border-bottom: 1px solid #EFEFEF;
			padding: 30rpx;
		}
	}
</style>
